//
//  UIImageView+Extension.swift
//  JKWeibo
//
//  Created by albert on 16/5/16.
//  Copyright © 2016年 albert. All rights reserved.
//  直接设置imageView的图片为圆形图片

import UIKit
import SDWebImage

extension UIImageView {
    /** 设置圆形头像 */
    func setCircleHeaderIcon(urlStr: String?){
        guard let urlString = urlStr else {
            return
        }
        
        let url = NSURL(string: urlString)
        
        guard let urlTrue = url else {
            return
        }
        
        let placeHolderImage = UIImage.circleImage("avatar_default")
        
        self.sd_setImageWithURL(urlTrue, placeholderImage: placeHolderImage, completed: { (img, err, SDImageCacheType, url) -> Void in
            
            self.image = (img != nil) ? img.circleImage() : placeHolderImage
        })
    }
}